package routers

import (
	"github.com/gin-gonic/gin"
	"muziai-server/api"
	"muziai-server/middleware"
)

func UserRouter(r *gin.RouterGroup) {
	middleware := middleware.MiddlewareAuth{}
	app := api.ApiApp.UserApi
	r.POST("login", app.LoginView)
	r.GET("captcha", app.CaptchaView)
	r.GET("userinfo", middleware.MiddlewareAuth(), app.UserInfoView)                 // 用户信息
	r.GET("userinfo/card", middleware.MiddlewareAuth(), app.UserCardInfoView)        // 用户信息
	r.PUT("userinfo", middleware.MiddlewareAuth(), app.UpdateUserInfoView)           //修改用户信息
	r.PUT("userinfo/admin", middleware.MiddlewareAdmin, app.AdminUpdateUserInfoView) //管理员修改用户信息
	r.GET("logout", middleware.MiddlewareAuth(), app.LogoutView)                     //用户注销
	r.POST("bind_password", middleware.MiddlewareAuth(), app.BindPasswordView)       //绑定密码
	r.POST("update_password", middleware.MiddlewareAuth(), app.UpdatePasswordView)   //修改密码
	r.POST("password_login", app.PasswordLoginView)                                  //密码登录
	r.POST("bind_account", middleware.MiddlewareAuth(), app.BindAccountView)         //绑定账号
	r.GET("user_login", middleware.MiddlewareAuth(), app.UserLoginListView)          //用户登录的设备列表
	r.POST("user_login", middleware.MiddlewareAuth(), app.UserLoginLoseView)         //让某个设备登录失效
	r.POST("user_login/admin", middleware.MiddlewareAuth(), app.AdminLoginLoseView)  //管理员让某个设备登录失效
	r.GET("users", middleware.MiddlewareAdmin, app.UserListView)
	r.GET("users/options", middleware.MiddlewareAdmin, app.UserOptionsView)

}
